,--------------------------------. | ASM Hacking for Dummies - v1.0 | | by SysTEm[id] | | http://id.dragonfire.net | `--------------------------------' Table of Contents -------------------------------------------------------------------------- 1.0 Introduction 2.0 About the 65c816 3.0 Language Structure 4.0 Expanding a ROM 4.1 Chart of ROM sizes in Mbits 5.0 Pointer Structure 5.1 LoRom Address Equation 5.2 Pointer Equations 6.0 Title Screen Replacement 6.1 Programs to Use 7.0 A Simple Fadeout Routine 8.0 Where to Get Needed Tools 9.0 Credits 9.1 Document Information Appendix A - 65c816 Instruction Set & Syntax -------------------------------------------------------------------------- 1.0 Introduction This document was written for the aspiring ROM hacker with little to no experience in 65c816 programming. The basics have been thouroughly covered and I believe this should prove a significant aid to anyone interested in 65c816 ROM hacking. Hopefully this proves true. If you benefit from this document or have suggestions for changes to make to it, please eMail me at shadow@chan.co.jp with your comments. In the end, you the user determines the future of this document. For updates to this document check http://id.dragonfire.net/ ... Unless of course it is now the year 2001 and this has become another document floating around on an FTP with some author nobody knows what happened to. Then yer up shit creek :-) -------------------------------------------------------------------------- 2.0 About the 65c816 This processor was Nintendo's pride and joy for quite a few years. Basically, it is an upgrade to the good ole 6502 processor used in such popular systems as the NES and the Commodore Amiga. The main feature added was 24 bit addressing but the processor also supported a whole slew of new instructions and lots of other fetures you don't need to know about. Basically, this little guy chugged along at a whopping 2.68Mhz, not even as fast as the Sega Genesis though a couple years later. But the main power was it's ability to display 256 colors in four different layers on screen at a time. That and a lot of other super-neat things helped it in competeing on the 16-bit market and earn a place in all our hearts. -------------------------------------------------------------------------- 3.0 Language Structure Well, time to make things get very very ugly. I'm sure you all are used to things like QBasic or C where you get to type in commands like; 10 Print "Hello World!" or cout<<"Hello World!"<0 wait CPY #$0000 ; x=0 BNE loop ; if y<>1 loop LDX #$00cf dark LDA $4210 ; vertical blank active? AND #$80 BEQ dark ; if no, do dark DEX CPX #$0000 BNE dark ; if x<>0 then dark This is closely based off of one of BeXXX's examples for a fadeout. But instead of drunked german notation, it has fairly understandable english notation so hopefully youc an now see the logic of this. Basically it's a looping routine that keeps decreasing the lightness to dark untill the screen is blanked. -------------------------------------------------------------------------- 8.0 Where to Get Needed Tools I have a wide selection of tools at my webpage in the 65c816 section. http://id.dragonfire.net/ You can also get many things in terri public ftp. ftp://teeri.oulu.fi/pub/console/nintendo/ -------------------------------------------------------------------------- 9.0 Credits The following people have contributed to this text (whether they know it or not). Many many thanks go out to them. ,----------------------------------------------------------------------. | Neill Corlett - reminded me of the lorom equation one time when I | | forgot it | | Frank Hughes - tons of help and elpaling back when I was working on | | Ranma | | Jeremy Chadwick - putting up with my stupid questions back when I | | was first learning | | Carnivore - made a super-keen instruction -> ouput table I use | | Amalgam - making sure this was semi-comprehensible | `----------------------------------------------------------------------' -------------------------------------------------------------------------- 9.1 Document Information Questions, comments or complaints can be sent to me via eMail at shadow@chan.co.jp. Copyright c 1999 SysTEm[id]. All rights reserved. Last updated Sunday, April 25, 1999 -------------------------------------------------------------------------- Appendix A - 65c816 Instruction Set & Syntax OpCode Description Syntax --------------------------------------------------- SEP Set Bits in P sep #$30 ADC Add With Carry adc #$12 AND Logical AND and #$12 BIT Bit Test bit #$12 CMP Compare Accumulator cmp #$12 CPX Compare X Register cpx #$12 CPY Compare Y Register cpy #$12 DEC Decrement Accumulator or Memory dec $12 EOR Exclusive OR Accumulator eor #$12 INC Increment Accumulator or Memory inc $12 LDA Load Accumulator lda $12 LDX Load X Register ldx #$12 LDY Load Y Register ldy #$12 ORA Logical OR Accumulator ora #$12 ROL Rotate Left Acc or Mem rol $12 ROR Rotate Right Acc or Mem ror $12 SBC Subtract With Carry sbc #$12 STA Store Accumulator sta $12 STZ Store X Register stx $12 STY Store Y Register sty $12 CLR Store a 0 into Memory clr $12 BCC Branch if Carry Clear bcc $601e5 BCS Branch if Carry Set bcs $601e5 BEQ Branch if Equal beq $601e5 BMI Branch if Minus bmi $601e5 BNE Branch if Not Equal bne $601e5 BPL Branch if Plus bpl $601e5 BRA Branch Always bra $601e5 BVC Branch if Overflow Clear bvc $601e5 BVS Branch if Overflow Set bvs $601e5 CLC Clear the Carry Flag clc CLD Clear the Decimal Flag cld CLI Clear the Interrupt Flag cli DEX Decrement X Register dex DEY Decrement Y Register dey INX Increment X Register inx INY Increment Y Register iny NOP No Operation nop PLA Pop Accumulator pla PLP Pop P plp PLX Pop X Register plx PLY Pop Y Register ply SED Set Decimal Flag sed SEI Set Interrupt Flag sri TAX Transfer Accumulator to X tax TAY Transfer Accumulator to Y tay TSX Transfer S to X tsx TXA Transfer X to Accumulator txa TXS Transfer X to S txs TXY Transfer X to Y txy TYA Transfer Y to Accumulator tya XCE Exchange Carry w/ Emulation Bit xce BRK Break Point Instruction brk #$12 CSP Call System Procedure csp #$12 JMP Jump to New Location jmp $1234 JSR Jump to Subroutine jsr $1234 MVN Block Move (decrement) mvn $1234 MVP Block Move (increment) mvp $1234 RTI Return From Interrupt rti RTL Return From Long Subroutine rtl RTS Return From Short Subroutine rts HLT Halt the Clock hlt WAI Wait for Interrupt wai SWA Swap Accumulator swa I know this list is missing a lot of instructions, this is just the list of instructions I know for certain is supported by all the assemblers out there. Sorry to tell you but there is even more to learn. Hope this helps you to make sense out of some of assembler mess early on in the document.